<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>

<?php
	$dt = new myDateTime($sf_request->getParameter('date', date('Y-m-d')));
	$dt->debut_semaine();
	$dt_semaine_suivante = $dt->copy();
	$dt_semaine_suivante->debut_semaine_suivante();
	$dt_semaine_precedente = $dt->copy();
	$dt_semaine_precedente->debut_semaine_precedente();
?>
Semaine du : <?php echo $dt->format('d/m/Y') ?>
<div class="action">
<?php echo link_to('Semaine précédente', 'planning/new_prev?date='.$dt_semaine_precedente->format('Y-m-d'), array('class' => 'action')) ?>
&nbsp;
<?php echo link_to('Semaine suivante', 'planning/new_prev?date='.$dt_semaine_suivante->format('Y-m-d'), array('class' => 'action')) ?>
</div>


<form action="<?php echo url_for('planning/create_prev') ?>" method="post">
<?php echo $form->renderHiddenFields() ?>
<?php echo $form->renderGlobalErrors() ?>

<table class="liste">
	<tr>
		<th>Libellé</th>
		<th>Charge estimée</th>
		<th>Total consommé</th>
		<th>Total restant</th>
		<th>Prévision</th>
	</tr>
	<?php
	foreach ($phases as $phase) {
		echo '<tr class="sstitre">';
		echo '<td>'. $phase->getPlnphs_Libelle() .'</td>';
		echo '<td>'. $phase->getPlnphsChargeEstimee() .'</td>';
		echo '<td>'. $phase->getChargeConsommee() .'</td>';
		echo '<td>'. $phase->getChargeRestante() .'</td>';
		echo '<td />';
		echo '</tr>';

		foreach ($phase->getTachesPlanning() as $tache) {
			echo '<tr>';
			echo $form['prevs'][$tache->getPlntacId()]['plnchg_prj_id']->render();
			echo $form['prevs'][$tache->getPlntacId()]['plnchg_plntac_id']->render();
			echo '<td>'. $tache->getplntacLibelle() .'</td>';
			echo '<td>'. $tache->getPlntacChargeEstimee() .'</td>';
			echo '<td>'. $tache->getPlntacChargeConsommee() .'</td>';
			echo '<td>'. $tache->getPlntacChargeRestante() .'</td>';
			echo '<td>'; 
			echo $form['prevs'][$tache->getPlntacId()]['plnchg_charge_prevue']->renderError();
			echo $form['prevs'][$tache->getPlntacId()]['plnchg_charge_prevue']->render(array('size' => 2));
			echo '</tr>';
		}
	}
	?>
</table>

<input type="submit" value="Enregistrer">
</form>
